<template>
  <el-container ref="container">
    <el-header style="height:auto">
      <!-- 按钮集合 -->
      <buttonGroup :buttonGroups="buttonGroups" />
    </el-header>

    <el-main>
      <tableView :viewData="viewData"
                      :tree-props="treeProps"
                      :columnConfigs="columnConfigs"
                      :row-key="rowKey"
                      :load="load"
                      :lazy="lazy"
                      v-model="selectData"></tableView>
    </el-main>

  </el-container>
</template>

<script>
    import buttonGroup from '@/components/button/group'
    import tableView from '@/components/table/view'
    export default {
        components: {
            'buttonGroup': buttonGroup,
            'tableView': tableView,
        },
        data() {
            return {
                buttonGroups: [{
                    icon: "el-icon-plus",
                    text: "添 加",
                    type: 'primary',
                    _click: () => {
                        console.log(111)
                    }
                }, {
                    icon: "el-icon-search",
                    text: "搜 索",
                    type: 'primary',
                    _click: () => {}
                }],
                searchForm: {
                    type: "",
                    UnifiedExaminPredictName: "",
                    region: ""
                },
                selectData: [],

                //树形表格必备二条件 详见elmentui table
                rowKey: 'id',
                lazy: true,
                treeProps: {
                    children: 'children',
                    hasChildren: 'hasChildren'
                },

                viewData: [{"id":1,"name":"参保人员信息","pid":-1,"open":true,"isParent":true,"pageName":null,"url":"/cust/index","checked":false,"status":0,"sort":1,"children":[],"pname":null},{"id":2,"name":"参保人员申报","pid":-1,"open":true,"isParent":true,"pageName":null,"url":"/grant/index","checked":false,"status":0,"sort":2,"children":[],"pname":null},{"id":3,"name":"发放统计","pid":-1,"open":true,"isParent":true,"pageName":null,"url":"/grant/index","checked":false,"status":0,"sort":3,"children":[],"pname":null},{"id":4,"name":"操作统计","pid":-1,"open":true,"isParent":true,"pageName":null,"url":"/operate/index","checked":false,"status":0,"sort":4,"children":[],"pname":null},{"id":5,"name":"权限管理","pid":-1,"open":true,"isParent":true,"pageName":null,"url":" ","checked":false,"status":0,"sort":5,"children":[{"id":6,"name":"菜单管理","pid":5,"open":false,"isParent":false,"pageName":null,"url":"/manager/index","checked":false,"status":0,"sort":6,"children":[],"pname":"权限管理"},{"id":7,"name":"系统用户管理","pid":5,"open":false,"isParent":false,"pageName":null,"url":"/manager/index","checked":false,"status":0,"sort":7,"children":[],"pname":"权限管理"},{"id":8,"name":"系统角色管理","pid":5,"open":false,"isParent":true,"pageName":null,"url":"/role/index","checked":false,"status":0,"sort":8,"children":[{"id":9,"name":"1111","pid":8,"open":false,"isParent":false,"pageName":null,"url":"/role/index","checked":false,"status":0,"sort":9,"children":[],"pname":"系统角色管理"}],"pname":"权限管理"}],"pname":null}],

                columnConfigs: [{
                    prop: 'name',
                    label: '日期',
                    sortable: true
                }, {
                    prop: 'url',
                    label: '地址',
                }, {
                    prop: 'name',
                    label: '姓名',
                }],

            }
        },
        created() {

        },
        mounthed() {},
        methods: {
            load(tree, treeNode, resolve) {
                console.log(tree, treeNode, resolve)

                this.$message({
                    message: '恭喜你，您点击了预加载树形表格的操作按钮',
                    type: 'success'
                });

                setTimeout(() => {
                    resolve([{
                        id: 33,
                        date: '2016-05-01',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        id: 34,
                        date: '2016-05-01',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1519 弄'
                    }])
                }, 1000)

            }
        },
        watch: {}

    }
</script>